package com.taiji.web.controller.workOrder;

import java.util.List;
import javax.servlet.http.HttpServletResponse;

import com.taiji.workOrder.domain.WorkOrder;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import com.taiji.common.annotation.Log;
import com.taiji.common.core.controller.BaseController;
import com.taiji.common.core.domain.AjaxResult;
import com.taiji.common.enums.BusinessType;
import com.taiji.workOrder.service.ILeftProblemService;
import com.taiji.common.utils.poi.ExcelUtil;
import com.taiji.common.core.page.TableDataInfo;

/**
 * 遗留问题Controller
 * 
 * @author taiji
 * @date 2023-03-19
 */
@RestController
@RequestMapping("/workOrder/leftProblem")
@Api(tags="工单管理")
public class LeftProblemController extends BaseController
{
    @Autowired
    private ILeftProblemService leftProblemService;

    /**
     * 查询遗留问题列表
     */
    @PreAuthorize("@ss.hasPermi('workOrder:leftProblem:list')")
    @GetMapping("/list")
    @ApiOperation("查询遗留问题列表")
    public TableDataInfo list(WorkOrder leftProblem)
    {
        startPage();
        List<WorkOrder> list = leftProblemService.selectLeftProblemList(leftProblem);
        return getDataTable(list);
    }

    /**
     * 导出遗留问题列表
     */
    @PreAuthorize("@ss.hasPermi('workOrder:leftProblem:export')")
    @Log(title = "遗留问题", businessType = BusinessType.EXPORT)
    @PostMapping("/export")
    public void export(HttpServletResponse response, WorkOrder leftProblem)
    {
        List<WorkOrder> list = leftProblemService.selectLeftProblemList(leftProblem);
        ExcelUtil<WorkOrder> util = new ExcelUtil<WorkOrder>(WorkOrder.class);
        util.exportExcel(response, list, "遗留问题数据");
    }

    /**
     * 获取遗留问题详细信息
     */
    @PreAuthorize("@ss.hasPermi('workOrder:leftProblem:query')")
    @GetMapping(value = "/{id}")
    @ApiOperation("获取遗留问题详细信息")
    public AjaxResult getInfo(@PathVariable("id") String id)
    {
        return success(leftProblemService.selectLeftProblemById(id));
    }

    /**
     * 新增遗留问题
     */
    @PreAuthorize("@ss.hasPermi('workOrder:leftProblem:add')")
    @Log(title = "遗留问题", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody WorkOrder leftProblem)
    {
        return toAjax(leftProblemService.insertLeftProblem(leftProblem));
    }

    /**
     * 修改遗留问题
     */
    @PreAuthorize("@ss.hasPermi('workOrder:leftProblem:edit')")
    @Log(title = "遗留问题", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody WorkOrder leftProblem)
    {
        return toAjax(leftProblemService.updateLeftProblem(leftProblem));
    }

    /**
     * 删除遗留问题
     */
    @PreAuthorize("@ss.hasPermi('workOrder:leftProblem:remove')")
    @Log(title = "遗留问题", businessType = BusinessType.DELETE)
	@DeleteMapping("/{ids}")
    public AjaxResult remove(@PathVariable String[] ids)
    {
        return toAjax(leftProblemService.deleteLeftProblemByIds(ids));
    }
}
